home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / bench / RCS / bench.c,v < prev    next >
Text File  |  1990-09-24  |  24KB  |  1,206 lines

  1. head     1.18;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.18
  10. date     90.02.16.11.10.43;  author jhh;  state Exp;
  11. branches ;
  12. next     1.17;
  13.  
  14. 1.17
  15. date     89.08.03.16.07.53;  author brent;  state Exp;
  16. branches ;
  17. next     1.16;
  18.  
  19. 1.16
  20. date     89.01.31.13.37.05;  author david;  state Exp;
  21. branches ;
  22. next     1.15;
  23.  
  24. 1.15
  25. date     89.01.04.15.37.10;  author david;  state Exp;
  26. branches ;
  27. next     1.14;
  28.  
  29. 1.14
  30. date     88.09.29.17.02.44;  author david;  state Exp;
  31. branches ;
  32. next     1.13;
  33.  
  34. 1.13
  35. date     88.09.26.10.28.51;  author nelson;  state Exp;
  36. branches ;
  37. next     1.12;
  38.  
  39. 1.12
  40. date     88.09.13.13.35.54;  author nelson;  state Exp;
  41. branches ;
  42. next     1.11;
  43.  
  44. 1.11
  45. date     88.09.12.18.43.10;  author nelson;  state Exp;
  46. branches ;
  47. next     1.10;
  48.  
  49. 1.10
  50. date     88.09.08.20.22.32;  author nelson;  state Exp;
  51. branches ;
  52. next     1.9;
  53.  
  54. 1.9
  55. date     87.12.31.16.02.10;  author nelson;  state Exp;
  56. branches ;
  57. next     1.8;
  58.  
  59. 1.8
  60. date     87.12.23.17.31.00;  author nelson;  state Exp;
  61. branches ;
  62. next     1.7;
  63.  
  64. 1.7
  65. date     87.12.22.10.27.09;  author brent;  state Exp;
  66. branches ;
  67. next     1.6;
  68.  
  69. 1.6
  70. date     87.12.22.10.15.12;  author brent;  state Exp;
  71. branches ;
  72. next     1.5;
  73.  
  74. 1.5
  75. date     87.08.22.16.16.35;  author brent;  state Exp;
  76. branches ;
  77. next     1.4;
  78.  
  79. 1.4
  80. date     87.08.17.13.07.10;  author nelson;  state Exp;
  81. branches ;
  82. next     1.3;
  83.  
  84. 1.3
  85. date     87.07.14.10.26.09;  author brent;  state Exp;
  86. branches ;
  87. next     1.2;
  88.  
  89. 1.2
  90. date     87.05.01.15.52.24;  author brent;  state Exp;
  91. branches ;
  92. next     1.1;
  93.  
  94. 1.1
  95. date     87.04.01.10.40.27;  author brent;  state Exp;
  96. branches ;
  97. next     ;
  98.  
  99.  
  100. desc
  101. @Benchmarking program to measure resourse usage.  Runs either stand alone
  102. or it synchronizes N clients and a server.
  103. @
  104.  
  105.  
  106. 1.18
  107. log
  108. @Option to start server on signal
  109. @
  110. text
  111. @/*
  112.  * A standard harness with which to benchmark programs.
  113.  * This sets up statistics stuff, then forks and execs a
  114.  * program to benchmark.  When the program completes, its
  115.  * resource usage is recorded, as well as other filesystem
  116.  * related statistics.
  117.  *
  118.  * The programs output goes to standard out, while the
  119.  * statistics taken go to error output or another file.
  120.  */
  121.  
  122. #include "sprite.h"
  123. #include "status.h"
  124. #include "sys/ioctl.h"
  125. #include "sys/file.h"
  126. #include "fs.h"
  127. #include "fsCmd.h"
  128. #include "sysStats.h"
  129. #include "proc.h"
  130. #include "vm.h"
  131. #include "kernel/sched.h"
  132. #include "kernel/fsStat.h"
  133. #include "kernel/vm.h"
  134. #include "kernel/net.h"
  135. #include "option.h"
  136. #include "sig.h"
  137. #include "signal.h"
  138. #include "stdio.h"
  139. #ifdef spur
  140. #include "ccMachStat.h"
  141. #endif
  142. Boolean flushCache = FALSE;
  143. Boolean clean = FALSE;
  144. Boolean exec = FALSE;
  145. Boolean histogram = FALSE;
  146. int numClients = -1;            /* For multi-program synchronization,
  147.                      * this is the number of slaves with
  148.                      * which to synchronize */
  149. Boolean slave = FALSE;
  150. char *outFile = "bench.out";
  151. extern char *pdev;
  152. Boolean    dontSyncCache = FALSE;
  153. Boolean    useSignals = FALSE;
  154. int    pause = 0;
  155. Boolean waitForSignal = FALSE;
  156.  
  157. Option optionArray[] = {
  158.     {OPT_STRING, "o", (Address)&outFile,
  159.         "Output file name\n"},
  160.     {OPT_STRING, "p", (Address)&pdev,
  161.         "Name of the master pseudo device\n"},
  162.     {OPT_TRUE, "f", (Address)&flushCache,
  163.         "Flush cache before benchmark"},
  164.     {OPT_TRUE, "x", (Address)&clean,
  165.         "Turn off all tracing"},
  166.     {OPT_TRUE, "h", (Address)&histogram,
  167.         "Leave histograms on (ok with -x)"},
  168.     {OPT_TRUE, "S", (Address)&slave,
  169.         "Slave bench program"},
  170.     {OPT_INT, "M", (Address)&numClients,
  171.         "Master for -M (int) clients"},
  172.     {OPT_TRUE, "d", (Address)&dontSyncCache,
  173.         "Dont sync the cache when done"},
  174.     {OPT_TRUE, "s", (Address)&useSignals,
  175. "Use signals to rendevous the master and slave instead of pseudo-devices.\n"},
  176.     {OPT_INT, "P", (Address)&pause,
  177.         "Seconds to pause before get final stats"},
  178.     {OPT_REST, "c", (Address)&exec,
  179.         "(Follow with command to benchmark)"},
  180.     {OPT_TRUE, "w", (Address) &waitForSignal,
  181.         "Master waits for USR1 signal before starting slaves.\n"},
  182. };
  183. int numOptions = sizeof(optionArray) / sizeof(Option);
  184.  
  185. Fs_Stats fsStartStats, fsEndStats;
  186. Vm_Stat    vmStartStats, vmEndStats;
  187. Sys_DiskStats    diskStartStats[10], diskEndStats[10];
  188.  
  189. Time startTime, endTime;
  190. Sched_Instrument startSchedStats, endSchedStats;
  191. Net_EtherStats    netStartStats, netEndStats;
  192.  
  193. #ifdef spur
  194. MachStats startMachStats, endMachStats;
  195. #endif
  196.  
  197. #define NUM_PCBS    256
  198. Proc_ControlBlock pcbs1[NUM_PCBS];
  199. Proc_ControlBlock pcbs2[NUM_PCBS];
  200. Proc_PCBArgString argStrings1[NUM_PCBS];
  201. Proc_PCBArgString argStrings2[NUM_PCBS];
  202. int numPCB1, numPCB2;
  203.  
  204. extern void ServerSetup();
  205. extern void Serve();
  206.  
  207. extern void ClientSetup();
  208. extern void ClientDone();
  209.  
  210. extern void PrintTimes();
  211. extern void PrintIdleTime();
  212. extern void PrintFsStats();
  213. extern void PrintVmStats();
  214. extern void PrintDiskStats();
  215.  
  216. extern int errno;
  217.  
  218. Boolean    gotSig = FALSE;
  219. Boolean startClients = FALSE;
  220.  
  221. main(argc, argv)
  222.     int argc;
  223.     char *argv[];
  224. {
  225.     register ReturnStatus status = SUCCESS;
  226.     Proc_PID child;
  227.     Proc_ResUsage usage;
  228.     FILE *outStream;
  229.     int i;
  230.     ClientData serverData, clientData;
  231.     int    mastPID;
  232.     int    pidFD;
  233.  
  234.  
  235.     argc = Opt_Parse(argc, argv, optionArray, numOptions, 0);
  236.     if (!exec && (numClients < 0)) {
  237.     fprintf(stderr, "Master: %s [-xfh] -M numSlaves\n", argv[0]);
  238.     fprintf(stderr, 
  239.         "Slave: %s [-xfh] -S -c commandPathName flags...\n", argv[0]);
  240.     Opt_PrintUsage(argv[0], optionArray, numOptions);
  241.     exit(1);
  242.     }
  243.     if ((numClients < 0) && waitForSignal) {
  244.     fprintf(stderr,"The -w flag can only be used with the -M flag.\n");
  245.     Opt_PrintUsage(argv[0], optionArray, numOptions);
  246.     exit(1);
  247.     }
  248.     if (waitForSignal) {
  249.     int HandleUSR1();
  250.     (void) signal(SIGUSR1, HandleUSR1);
  251.     }
  252.     if (clean) {
  253.     int newValue;
  254.     newValue = 0;
  255.     Fs_Command(FS_SET_CACHE_DEBUG, sizeof(int), (Address) &newValue);
  256.     newValue = 0;
  257.     Fs_Command(FS_SET_TRACING, sizeof(int), (Address) &newValue);
  258.     newValue = 0;
  259.     Fs_Command(FS_SET_RPC_DEBUG, sizeof(int), (Address) &newValue);
  260.     newValue = 0;
  261.     Fs_Command(FS_SET_RPC_TRACING, sizeof(int), (Address) &newValue);
  262.     if (!histogram) {
  263.         newValue = 0;
  264.         (void) Fs_Command(FS_SET_RPC_SERVER_HIST, sizeof(int),
  265.                 (Address) &newValue);
  266.         newValue = 0;
  267.         (void) Fs_Command(FS_SET_RPC_CLIENT_HIST, sizeof(int),
  268.                 (Address) &newValue);
  269.     }
  270.     }
  271.     if (flushCache) {
  272.     int numLockedBlocks = 0;
  273.     Fs_Command(FS_EMPTY_CACHE, sizeof(int), (Address) &numLockedBlocks);
  274.         if (numLockedBlocks > 0) {
  275.             fprintf(stderr, "Flush found %d locked blocks left\n",
  276.                                       numLockedBlocks);
  277.         }
  278.     }
  279.     outStream = fopen(outFile, "w+");
  280.     if (outStream == NULL) {
  281.     fprintf(stderr, "\"%s\": ", outFile);
  282.     Stat_PrintMsg(status, "Can't open");
  283.     exit(status);
  284.     }
  285.     /*
  286.      * Copy command line to output file.
  287.      */
  288.     fprintf(outStream, "%s ", argv[0]);
  289.     if (clean) {
  290.     fprintf(outStream, "-x ");
  291.     }
  292.     if (histogram) {
  293.     fprintf(outStream, "-h ");
  294.     }
  295.     if (flushCache) {
  296.     fprintf(outStream, "-f ");
  297.     }
  298.     if (clean) {
  299.     fprintf(outStream, "-x ");
  300.     }
  301.     for (i=1 ; i<argc ; i++) {
  302.     fprintf(outStream, "%s ", argv[i]);
  303.     }
  304.     fprintf(outStream, "\n");
  305.     if (useSignals) {
  306.     if (numClients > 0) {
  307.         int        bytesWritten;
  308.         Sig_Action    newAction, oldAction;
  309.         int        Handler();
  310.  
  311.         newAction.action = SIG_HANDLE_ACTION;
  312.         newAction.handler = Handler;
  313.         newAction.sigHoldMask = 0;
  314.         Sig_SetAction(30, &newAction, &oldAction);
  315.         /*
  316.          * Get our PID and store it in a file.
  317.          */
  318.         Proc_GetIDs(&mastPID, NULL, NULL, NULL);
  319.         pidFD = open("/tmp/db.pid", 
  320.                 O_WRONLY | O_CREAT | O_TRUNC,
  321.                 0666, &pidFD);
  322.         if (pidFD == NULL) {
  323.         fprintf(stderr,
  324.             "Master: Couldn't open pid file, status <%x>\n",
  325.             errno);
  326.         exit(errno);
  327.         }
  328.         bytesWritten = write(pidFD, &mastPID, sizeof(int));
  329.         while (!gotSig) {
  330.         Sig_Pause(0);
  331.         }
  332.         gotSig = FALSE;
  333.         printf("Got start signal\n");
  334.         fflush(stdout);
  335.     }
  336.     if (slave) {
  337.         int    bytesRead;
  338.         /*
  339.          * Read the master's pid out of the pid file and send him a 
  340.          * signal.
  341.          */
  342.         do {
  343.         pidFD = open("/tmp/db.pid", O_RDONLY, 0);
  344.         if (pidFD < 0) {
  345.             fprintf(stderr,
  346.         "Slave: Couldn't open pid file, status <%x>, pausing 5 seconds\n",
  347.             errno);
  348.             Sync_WaitTime(5, 0);
  349.             continue;
  350.         }
  351.         mastPID = 0;
  352.         bytesRead = read(pidFD, &mastPID, sizeof(int));
  353.         status = Sig_Send(30, mastPID, FALSE);
  354.         if (status == SUCCESS) {
  355.             /*
  356.              * Pause for one second to let the master receive
  357.              * our signal and gather stats.
  358.              */
  359.             Sync_WaitTime(1, 0);
  360.             break;
  361.         }
  362.         fprintf(stderr,
  363.         "Slave: couldn't signal parent, status <%x>, pausing 5 seconds\n",
  364.             status);
  365.         close(pidFD);
  366.         Sync_WaitTime(5, 0);
  367.         continue;
  368.         } while (TRUE);
  369.     }
  370.     } else {
  371.     /*
  372.      * Check for multi-program master/slave setup.
  373.      */
  374.     if (numClients > 0) {
  375.         ServerSetup(numClients, &serverData);
  376.         slave = FALSE;
  377.     }
  378.     if (slave) {
  379.         ClientSetup(&clientData);
  380.     }
  381.     }
  382.     /*
  383.      * Get first sample of filesystem stats, vm stats, time, and idle ticks.
  384.      */
  385.     status = Fs_Command(FS_RETURN_STATS, sizeof(Fs_Stats),
  386.             (Address) &fsStartStats);
  387.     if (status != SUCCESS) {
  388.     Stat_PrintMsg(status, "Error getting FS stats");
  389.     exit(status);
  390.     }
  391.     status = Sys_Stats(SYS_VM_STATS, 0, (Address) &vmStartStats);
  392.     if (status != SUCCESS) {
  393.     Stat_PrintMsg(status, "Error getting VM stats");
  394.     exit(status);
  395.     }
  396.     status = Sys_Stats(SYS_DISK_STATS, 10, diskStartStats);
  397.     if (status != SUCCESS) {
  398.     Stat_PrintMsg(status, "Error getting Disk stats");
  399.     exit(status);
  400.     }
  401.     /*
  402.      * Clear low and high water marks for the file system cache.
  403.      */
  404.     status = Vm_Cmd(VM_RESET_FS_STATS, 0);
  405.     if (status != SUCCESS) {
  406.     Stat_PrintMsg(status, "Error resetting fs low and high water marks\n");
  407.     }
  408.     status = Sys_Stats(SYS_NET_ETHER_STATS, 0, (Address) &netStartStats);
  409.     if (status != SUCCESS) {
  410.     Stat_PrintMsg(status, "Error getting NET stats");
  411.     exit(status);
  412.     }
  413.     /*
  414.      * Snapshot the process table so we can apportion CPU usage
  415.      * to various processes.
  416.      */
  417.     numPCB1 = GetProcTable(NUM_PCBS, pcbs1, argStrings1);
  418.  
  419.     status = Sys_GetTimeOfDay(&startTime, NULL, NULL);
  420.     if (status != SUCCESS) {
  421.     Stat_PrintMsg(status, "Error in Sys_GetTimeOfDay");
  422.     exit(status);
  423.     }
  424.     status = Sys_Stats(SYS_SCHED_STATS, 0, (Address) &startSchedStats);
  425.     if (status != SUCCESS) {
  426.     Stat_PrintMsg(status, "Error in Sys_Stats");
  427.     exit(status);
  428.     }
  429. #ifdef spur
  430.     status = InitMachStats( (Address) &startMachStats, MODE_PERF_COUNTER_OFF);
  431.     if (status != SUCCESS) {
  432.     Stat_PrintMsg(status, "Error in InitMachStats");
  433.         exit(status);
  434.     }
  435. #endif
  436.     if (slave || numClients < 0) {
  437.     status = Proc_Fork(FALSE, &child);
  438.     if (status == PROC_CHILD_PROC) {
  439.         /*
  440.          * Put ourselves in our own family.
  441.          */
  442.         (void) Proc_SetFamilyID(PROC_MY_PID, child);
  443.         (void) Ioc_SetOwner (0, child, IOC_OWNER_FAMILY);
  444.         /*
  445.          * Exec the program to benchmark.  Opt_Parse has left the command
  446.          * starting at argv[1], hence the following argv++.
  447.          */
  448.         argv++;
  449.         status = Proc_Exec(argv[0], argv, FALSE);
  450.         if (status != SUCCESS) {
  451.         fprintf(stderr,"Exec of \"%s\" failed",argv[0]);
  452.         Stat_PrintMsg(status, "");
  453.         fflush(stdout);
  454.         exit(status);
  455.         }
  456.     } else if (status == SUCCESS) {
  457.         /*
  458.          * Wait for the benchmark to complete.
  459.          */
  460.         status = Proc_Wait(0, NULL, TRUE, NULL,
  461.                   NULL, NULL, NULL, &usage);
  462.         if (status != SUCCESS) {
  463.         Stat_PrintMsg(status, "Error in Proc_Wait");
  464.         exit(status);
  465.         }
  466.         /*
  467.          * Take ending statistics and print user, system, and elapsed times.
  468.          */
  469. #ifdef spur
  470.         status = GetMachStats( (Address) &endMachStats);
  471.         if (status != SUCCESS) {
  472.         Stat_PrintMsg(status, "Error in GetMachStats");
  473.         exit(status);
  474.         };
  475. #endif
  476.         Sys_GetTimeOfDay(&endTime, NULL, NULL);
  477.         Sys_Stats(SYS_SCHED_STATS, 0, (Address) &endSchedStats);
  478.         Time_Subtract(endTime, startTime, &endTime);
  479.         PrintTimes(stderr, &usage, &endTime);
  480.         if (!dontSyncCache) {
  481.         Sys_Shutdown(SYS_WRITE_BACK, "");    /* sync cache */
  482.         }
  483.         if (slave) {
  484.         if (useSignals) {
  485.             status = Sig_Send(30, mastPID, FALSE);
  486.             if (status != SUCCESS) {
  487.             fprintf(stderr,
  488.                 "Slave: couldn't signal parent (2), status <%x>\n",
  489.                 status);
  490.             }
  491.         } else {
  492.             ClientDone(clientData);
  493.         }
  494.         }
  495.         numPCB2 = GetProcTable(NUM_PCBS, pcbs2, argStrings2);
  496.         Fs_Command(FS_RETURN_STATS, sizeof(Fs_Stats), (Address) &fsEndStats);
  497.         Sys_Stats(SYS_VM_STATS, 0, (Address) &vmEndStats);
  498.         Sys_Stats(SYS_DISK_STATS, 10, diskEndStats);
  499.         Sys_Stats(SYS_NET_ETHER_STATS, 0, (Address) &netEndStats);
  500.         /*
  501.          * Print FS statistics.
  502.          */
  503.         PrintTimes(outStream, &usage, &endTime);
  504.         PrintIdleTime(outStream, &startSchedStats, &endSchedStats, &endTime);
  505.         PrintFsStats(outStream, &fsStartStats, &fsEndStats, TRUE);
  506.         PrintDiskStats(outStream, diskStartStats, diskEndStats);
  507.         /*
  508.          * Print VM statistics.
  509.          */
  510.         PrintVmStats(outStream, &vmStartStats, &vmEndStats);
  511.         /*
  512.          * Print network statistics.
  513.          */
  514.         fprintf(outStream,
  515.             "Network stats: Bytes received %d bytes sent %d\n",
  516.             netEndStats.bytesReceived - netStartStats.bytesReceived,
  517.             netEndStats.bytesSent - netStartStats.bytesSent);
  518.         /*
  519.          * Print out process info.
  520.          */
  521.         PrintProcStats(outStream, numPCB1, pcbs1, argStrings1,
  522.                       numPCB2, pcbs2, argStrings2);
  523. #ifdef spur
  524.         /*
  525.          * Print Machine dependent stats
  526.          */
  527.         PrintMachStats(outStream, &startMachStats, &endMachStats);
  528. #endif
  529.     } else {
  530.         Stat_PrintMsg(status, "Error in Proc_Fork");
  531.     }
  532.     } else {
  533.     if (useSignals) {
  534.         while (!gotSig) { 
  535.         Sig_Pause(0);
  536.         }
  537.         printf("Got end signal\n");
  538.         fflush(stdout);
  539.     } else {
  540.         Serve(serverData);
  541.     }
  542.     if (pause) {
  543.         sleep(pause);
  544.     }
  545. #ifdef spur
  546.     /*
  547.      * Take ending statistics and print user, system, and elapsed times.
  548.      */
  549.     status = GetMachStats( (Address) &endMachStats);
  550.     if (status != SUCCESS) {
  551.         Stat_PrintMsg(status, "Error in GetMachStats");
  552.         exit(status);
  553.     };
  554. #endif
  555.     Sys_GetTimeOfDay(&endTime, NULL, NULL);
  556.     Sys_Stats(SYS_SCHED_STATS, 0, (Address) &endSchedStats);
  557.     Time_Subtract(endTime, startTime, &endTime);
  558.     PrintTimes(stderr, &usage, &endTime);
  559.  
  560.     if (!dontSyncCache) {
  561.         Sys_Shutdown(SYS_WRITE_BACK, "");    /* sync cache */
  562.     }
  563.     Fs_Command(FS_RETURN_STATS, sizeof(Fs_Stats), (Address) &fsEndStats);
  564.     Sys_Stats(SYS_VM_STATS, 0, (Address) &vmEndStats);
  565.     Sys_Stats(SYS_DISK_STATS, 10, diskEndStats);
  566.     Sys_Stats(SYS_NET_ETHER_STATS, 0, (Address) &netEndStats);
  567.     /*
  568.      * Print FS statistics.
  569.      */
  570.     PrintTimes(outStream, &usage, &endTime);
  571.     PrintIdleTime(outStream, &startSchedStats, &endSchedStats, &endTime);
  572.     PrintFsStats(outStream, &fsStartStats, &fsEndStats, TRUE);
  573.     PrintDiskStats(outStream, diskStartStats, diskEndStats);
  574.     /*
  575.      * Print VM statitistics.
  576.      */
  577.     PrintVmStats(outStream, &vmStartStats, &vmEndStats);
  578.     /*
  579.      * Print network statistics.
  580.      */
  581.     fprintf(outStream,
  582.             "Network stats: Bytes received %d bytes sent %d\n",
  583.             netEndStats.bytesReceived - netStartStats.bytesReceived,
  584.             netEndStats.bytesSent - netStartStats.bytesSent);
  585. #ifdef spur
  586.     /*
  587.     ** Print Machine dependent stats
  588.     */
  589.     PrintMachStats(outStream, &startMachStats, &endMachStats);
  590. #endif
  591.     }
  592.     exit(status);
  593. }
  594.  
  595. int
  596. Handler()
  597. {
  598.     gotSig = TRUE;
  599. }
  600.  
  601. int
  602. HandleUSR1()
  603. {
  604.     startClients = TRUE;
  605. }
  606. @
  607.  
  608.  
  609. 1.17
  610. log
  611. @Fixed call to print Proc stats
  612. @
  613. text
  614. @d27 1
  615. d29 1
  616. d31 1
  617. a31 1
  618.  
  619. d45 1
  620. d70 2
  621. d75 1
  622. a75 1
  623. FsStats fsStartStats, fsEndStats;
  624. d83 1
  625. d85 1
  626. d109 1
  627. d133 9
  628. d275 1
  629. a275 1
  630.     status = Fs_Command(FS_RETURN_STATS, sizeof(FsStats),
  631. d319 1
  632. d325 1
  633. a325 1
  634.  
  635. d341 2
  636. a342 1
  637.         Stat_PrintMsg(status, "Exec failed");
  638. d359 1
  639. d365 1
  640. d386 1
  641. a386 1
  642.         Fs_Command(FS_RETURN_STATS, sizeof(FsStats), (Address) &fsEndStats);
  643. d413 1
  644. d418 1
  645. d435 1
  646. a435 1
  647.  
  648. d444 1
  649. d453 1
  650. a453 1
  651.     Fs_Command(FS_RETURN_STATS, sizeof(FsStats), (Address) &fsEndStats);
  652. d475 1
  653. d480 1
  654. d489 6
  655. @
  656.  
  657.  
  658. 1.16
  659. log
  660. @Added the machine dependent support that was lost when the file got
  661. munged.
  662. @
  663. text
  664. @d80 7
  665. d116 1
  666. d286 6
  667. d364 1
  668. a364 1
  669.  
  670. d388 7
  671. a394 2
  672.         ** Print Machine dependent stats
  673.         */
  674. @
  675.  
  676.  
  677. 1.15
  678. log
  679. @Convert to machine dependent format and prints SPUR cache controller
  680. register results.
  681. @
  682. text
  683. @d28 1
  684. d78 2
  685. d109 1
  686. a109 1
  687.     (void) Opt_Parse(argc, argv, optionArray, numOptions, 0);
  688. d114 1
  689. a114 1
  690.     Opt_PrintUsage(argv[0], numOptions, optionArray);
  691. d288 5
  692. d326 5
  693. d373 4
  694. d397 5
  695. d432 4
  696. @
  697.  
  698.  
  699. 1.14
  700. log
  701. @
  702. @
  703. text
  704. @@
  705.  
  706.  
  707. 1.13
  708. log
  709. @Can now make it sleep for a while after completion of the benchmark before
  710. getting the final stats.
  711. @
  712. text
  713. @d14 2
  714. a15 1
  715. #include "io.h"
  716. d27 1
  717. d44 1
  718. a44 1
  719.     {OPT_STRING, 'o', (Address)&outFile,
  720. d46 1
  721. a46 1
  722.     {OPT_STRING, 'p', (Address)&pdev,
  723. d48 1
  724. a48 1
  725.     {OPT_TRUE, 'f', (Address)&flushCache,
  726. d50 1
  727. a50 1
  728.     {OPT_TRUE, 'x', (Address)&clean,
  729. d52 1
  730. a52 1
  731.     {OPT_TRUE, 'h', (Address)&histogram,
  732. d54 1
  733. a54 1
  734.     {OPT_TRUE, 'S', (Address)&slave,
  735. d56 1
  736. a56 1
  737.     {OPT_INT, 'M', (Address)&numClients,
  738. d58 1
  739. a58 1
  740.     {OPT_TRUE, 'd', (Address)&dontSyncCache,
  741. d60 1
  742. a60 1
  743.     {OPT_TRUE, 's', (Address)&useSignals,
  744. d62 1
  745. a62 1
  746.     {OPT_INT, 'P', (Address)&pause,
  747. d64 1
  748. a64 1
  749.     {OPT_REST, 'c', (Address)&exec,
  750. d89 2
  751. d100 1
  752. a100 1
  753.     Io_Stream outStream;
  754. d106 1
  755. a106 1
  756.     (void) Opt_Parse(&argc, argv, numOptions, optionArray);
  757. d108 2
  758. a109 2
  759.     Io_PrintStream(io_StdErr, "Master: %s [-xfh] -M numSlaves\n", argv[0]);
  760.     Io_PrintStream(io_StdErr, 
  761. d112 1
  762. a112 1
  763.     Proc_Exit(1);
  764. d137 1
  765. a137 1
  766.             Io_PrintStream(io_StdErr, "Flush found %d locked blocks left\n",
  767. d141 3
  768. a143 3
  769.     outStream = Io_Open(outFile, "w+");
  770.     if (outStream == (Io_Stream)NULL) {
  771.     Io_PrintStream(io_StdErr, "\"%s\": ", outFile);
  772. d145 1
  773. a145 1
  774.     Proc_Exit(status);
  775. d150 1
  776. a150 1
  777.     Io_PrintStream(outStream, "%s ", argv[0]);
  778. d152 1
  779. a152 1
  780.     Io_PrintStream(outStream, "-x ");
  781. d155 1
  782. a155 1
  783.     Io_PrintStream(outStream, "-h ");
  784. d158 1
  785. a158 1
  786.     Io_PrintStream(outStream, "-f ");
  787. d161 1
  788. a161 1
  789.     Io_PrintStream(outStream, "-x ");
  790. d164 1
  791. a164 1
  792.     Io_PrintStream(outStream, "%s ", argv[i]);
  793. d166 1
  794. a166 1
  795.     Io_PrintStream(outStream, "\n");
  796. d181 2
  797. a182 2
  798.         status = Fs_Open("/tmp/db.pid", 
  799.                 FS_WRITE | FS_CREATE | FS_TRUNC,
  800. d184 2
  801. a185 2
  802.         if (status != SUCCESS) {
  803.         Io_PrintStream(io_StdErr,
  804. d187 2
  805. a188 2
  806.             status);
  807.         Proc_Exit(status);
  808. d190 1
  809. a190 1
  810.         Fs_Write(pidFD, sizeof(int), &mastPID, &bytesWritten);
  811. d195 2
  812. a196 2
  813.         Io_Print("Got start signal\n");
  814.         Io_Flush(io_StdOut);
  815. d205 3
  816. a207 3
  817.         status = Fs_Open("/tmp/db.pid", FS_READ, 0, &pidFD);
  818.         if (status != SUCCESS) {
  819.             Io_PrintStream(io_StdErr,
  820. d209 1
  821. a209 1
  822.             status);
  823. d214 1
  824. a214 1
  825.         Fs_Read(pidFD, sizeof(int), &mastPID, &bytesRead);
  826. d224 1
  827. a224 1
  828.         Io_PrintStream(io_StdErr,
  829. d227 1
  830. a227 1
  831.         Fs_Close(pidFD);
  832. d251 1
  833. a251 1
  834.     Proc_Exit(status);
  835. d256 1
  836. a256 1
  837.     Proc_Exit(status);
  838. d261 1
  839. a261 1
  840.     Proc_Exit(status);
  841. d273 1
  842. a273 1
  843.     Proc_Exit(status);
  844. d278 1
  845. a278 1
  846.     Proc_Exit(status);
  847. d283 1
  848. a283 1
  849.     Proc_Exit(status);
  850. d302 2
  851. a303 2
  852.         Io_Flush(io_StdOut);
  853.         Proc_Exit(status);
  854. d313 1
  855. a313 1
  856.         Proc_Exit(status);
  857. d321 1
  858. a321 1
  859.         PrintTimes(io_StdErr, &usage, &endTime);
  860. d329 1
  861. a329 1
  862.             Io_PrintStream(io_StdErr,
  863. d356 1
  864. a356 1
  865.         Io_PrintStream(outStream,
  866. d368 2
  867. a369 2
  868.         Io_Print("Got end signal\n");
  869.         Io_Flush(io_StdOut);
  870. d383 1
  871. a383 1
  872.     PrintTimes(io_StdErr, &usage, &endTime);
  873. d406 1
  874. a406 1
  875.     Io_PrintStream(outStream,
  876. d411 1
  877. a411 1
  878.     Proc_Exit(status);
  879. @
  880.  
  881.  
  882. 1.12
  883. log
  884. @Added stuff for when have a master.
  885. @
  886. text
  887. @d39 1
  888. d60 2
  889. d213 5
  890. d369 4
  891. @
  892.  
  893.  
  894. 1.11
  895. log
  896. @Fixed signal rendevous mechanism.
  897. @
  898. text
  899. @d374 1
  900. d382 1
  901. @
  902.  
  903.  
  904. 1.10
  905. log
  906. @Added disk stats.
  907. @
  908. text
  909. @d174 1
  910. a174 1
  911.         status = Fs_Open("/sprite/daemons/db.pid", 
  912. d198 1
  913. a198 1
  914.         status = Fs_Open("/sprite/daemons/db.pid", FS_READ, 0, &pidFD);
  915. @
  916.  
  917.  
  918. 1.9
  919. log
  920. @Added resetting of vm fs stats and puts child in a family named by its
  921. own pid.
  922. @
  923. text
  924. @d66 2
  925. d82 1
  926. d246 5
  927. d328 1
  928. d336 1
  929. @
  930.  
  931.  
  932. 1.8
  933. log
  934. @Added ability to use signals to synchronize instead of pseudo-devices.
  935. @
  936. text
  937. @d81 2
  938. d181 4
  939. a184 1
  940.         Sig_Pause(0);
  941. d243 7
  942. d270 5
  943. d343 3
  944. a345 1
  945.         Sig_Pause(0);
  946. d389 1
  947. @
  948.  
  949.  
  950. 1.7
  951. log
  952. @Fixed call to Sys_Shutdown.
  953. @
  954. text
  955. @d25 1
  956. d38 1
  957. d57 2
  958. d91 2
  959. d155 68
  960. a222 6
  961.     /*
  962.      * Check for multi-program master/slave setup.
  963.      */
  964.     if (numClients > 0) {
  965.     ServerSetup(numClients, &serverData);
  966.     slave = FALSE;
  967. a223 3
  968.     if (slave) {
  969.     ClientSetup(&clientData);
  970.     }
  971. d289 10
  972. a298 1
  973.         ClientDone(clientData);
  974. d325 7
  975. a331 1
  976.     Serve(serverData);
  977. d365 5
  978. @
  979.  
  980.  
  981. 1.6
  982. log
  983. @Removed some lint.
  984. @
  985. text
  986. @a75 2
  987. extern void PrintTimes();
  988. extern void PrintTimes();
  989. d91 2
  990. a92 1
  991.     Io_PrintStream(io_StdErr, "Slave: %s [-xfh] -S -c commandPathName flags...\n", argv[0]);
  992. d221 1
  993. a221 1
  994.         Sys_Shutdown(0);    /* sync cache */
  995. d261 1
  996. a261 1
  997.         Sys_Shutdown(0);    /* sync cache */
  998. d279 2
  999. a280 1
  1000.     Io_PrintStream(outStream, "Network stats: Bytes received %d bytes sent %d\n",
  1001. @
  1002.  
  1003.  
  1004. 1.5
  1005. log
  1006. @Converted from Test_Stats to Sys_Stats
  1007. @
  1008. text
  1009. @d66 13
  1010. d90 1
  1011. a90 1
  1012.     Opt_Parse(&argc, argv, numOptions, optionArray);
  1013. d100 1
  1014. a100 1
  1015.     Fs_Command(FS_SET_CACHE_DEBUG, sizeof(int), &newValue);
  1016. d102 1
  1017. a102 1
  1018.     Fs_Command(FS_SET_TRACING, sizeof(int), &newValue);
  1019. d104 1
  1020. a104 1
  1021.     Fs_Command(FS_SET_RPC_DEBUG, sizeof(int), &newValue);
  1022. d106 1
  1023. a106 1
  1024.     Fs_Command(FS_SET_RPC_TRACING, sizeof(int), &newValue);
  1025. d109 2
  1026. a110 1
  1027.         (void) Fs_Command(FS_SET_RPC_SERVER_HIST, sizeof(int), &newValue);
  1028. d112 2
  1029. a113 1
  1030.         (void) Fs_Command(FS_SET_RPC_CLIENT_HIST, sizeof(int), &newValue);
  1031. d118 1
  1032. a118 1
  1033.     Fs_Command(FS_EMPTY_CACHE, sizeof(int), &numLockedBlocks);
  1034. d163 2
  1035. a164 1
  1036.     status = Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsStartStats);
  1037. d169 1
  1038. a169 1
  1039.     status = Sys_Stats(SYS_VM_STATS, 0, &vmStartStats);
  1040. d174 1
  1041. a174 1
  1042.     status = Sys_Stats(SYS_NET_ETHER_STATS, 0, &netStartStats);
  1043. d184 1
  1044. a184 1
  1045.     status = Sys_Stats(SYS_SCHED_STATS, 0, &startSchedStats);
  1046. d218 1
  1047. a218 1
  1048.         Sys_Stats(SYS_SCHED_STATS, 0, &endSchedStats);
  1049. d224 3
  1050. a226 1
  1051.         if (slave) ClientDone(clientData);
  1052. d228 3
  1053. a230 3
  1054.         Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsEndStats);
  1055.         Sys_Stats(SYS_VM_STATS, 0, &vmEndStats);
  1056.         Sys_Stats(SYS_NET_ETHER_STATS, 0, &netEndStats);
  1057. d236 1
  1058. a236 1
  1059.         PrintFsStats(outStream, &fsStartStats, &fsEndStats);
  1060. d244 2
  1061. a245 1
  1062.         Io_PrintStream(outStream, "Network stats: Bytes received %d bytes sent %d\n",
  1063. d257 1
  1064. a257 1
  1065.     Sys_Stats(SYS_SCHED_STATS, 0, &endSchedStats);
  1066. d264 3
  1067. a266 3
  1068.     Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsEndStats);
  1069.     Sys_Stats(SYS_VM_STATS, 0, &vmEndStats);
  1070.     Sys_Stats(SYS_NET_ETHER_STATS, 0, &netEndStats);
  1071. d272 1
  1072. a272 1
  1073.     PrintFsStats(outStream, &fsStartStats, &fsEndStats);
  1074. @
  1075.  
  1076.  
  1077. 1.4
  1078. log
  1079. @Added network bytes stats.
  1080. @
  1081. text
  1082. @d16 2
  1083. a17 1
  1084. #include "rpc.h"
  1085. d153 1
  1086. a153 1
  1087.     status = Vm_Cmd(VM_GET_STATS, &vmStartStats);
  1088. d158 1
  1089. a158 1
  1090.     status = Vm_Cmd(10000, &netStartStats);
  1091. d168 1
  1092. a168 1
  1093.     status = Test_Stats(SCHED_STATS, 0, &startSchedStats);
  1094. d170 1
  1095. a170 1
  1096.     Stat_PrintMsg(status, "Error in Test_Stats");
  1097. d202 1
  1098. a202 1
  1099.         Test_Stats(SCHED_STATS, 0, &endSchedStats);
  1100. d211 2
  1101. a212 2
  1102.         Vm_Cmd(VM_GET_STATS, &vmEndStats);
  1103.         Vm_Cmd(10000, &netEndStats);
  1104. d238 1
  1105. a238 1
  1106.     Test_Stats(SCHED_STATS, 0, &endSchedStats);
  1107. d246 2
  1108. a247 2
  1109.     Vm_Cmd(VM_GET_STATS, &vmEndStats);
  1110.     Vm_Cmd(10000, &netEndStats);
  1111. @
  1112.  
  1113.  
  1114. 1.3
  1115. log
  1116. @Fiddled with the server interface
  1117. @
  1118. text
  1119. @d22 1
  1120. d35 1
  1121. d52 2
  1122. d63 1
  1123. d157 5
  1124. d204 3
  1125. a206 2
  1126.  
  1127.         Sys_Shutdown(0);    /* sync cache */
  1128. d211 1
  1129. d222 6
  1130. d241 3
  1131. a243 1
  1132.     Sys_Shutdown(0);    /* sync cache */
  1133. d246 1
  1134. d257 6
  1135. @
  1136.  
  1137.  
  1138. 1.2
  1139. log
  1140. @Modified bench.c to use pseudo-dev interface
  1141. @
  1142. text
  1143. @d33 1
  1144. a33 1
  1145. extern char *devBench;
  1146. d38 1
  1147. a38 1
  1148.     {OPT_STRING, 'p', (Address)&devBench,
  1149. a133 1
  1150.     ServerStart(serverData);
  1151. a137 1
  1152.     ClientStart(clientData);
  1153. d214 1
  1154. a214 1
  1155.     ServerWait(serverData);
  1156. @
  1157.  
  1158.  
  1159. 1.1
  1160. log
  1161. @Initial revision
  1162. @
  1163. text
  1164. @d9 1
  1165. a9 1
  1166.  * statistics taken go to error output.
  1167. d28 1
  1168. a28 1
  1169. int numSlaves = -1;            /* For multi-program synchronization,
  1170. d33 1
  1171. a33 1
  1172. extern char *masterPipe;
  1173. d38 2
  1174. a39 2
  1175.     {OPT_STRING, 'p', (Address)&masterPipe,
  1176.         "Name of the master pipe\n"},
  1177. d48 2
  1178. a49 2
  1179.     {OPT_INT, 'M', (Address)&numSlaves,
  1180.         "Master for -M (int) slaves"},
  1181. d69 1
  1182. a69 1
  1183.     ClientData masterData, slaveData;
  1184. d72 1
  1185. a72 1
  1186.     if (!exec && (numSlaves < 0)) {
  1187. d132 3
  1188. a134 3
  1189.     if (numSlaves > 0) {
  1190.     MasterSetup(numSlaves, &masterData);
  1191.     MasterStart(masterData);
  1192. d138 2
  1193. a139 2
  1194.     SlaveSetup(&slaveData);
  1195.     SlaveStart(slaveData);
  1196. d165 1
  1197. a165 1
  1198.     if (slave || numSlaves < 0) {
  1199. d198 1
  1200. a198 1
  1201.         if (slave) SlaveDone(slaveData);
  1202. d216 1
  1203. a216 1
  1204.     MasterWait(masterData);
  1205. @
  1206.